#-*- coding:utf-8 -*-
import os
import imp
import sys
import time
import json
import logging
import traceback
import urllib
import urllib2
import httplib
import gevent
import gevent.monkey
gevent.monkey.patch_all()
from gevent.queue import Queue

from common import core

reload(sys)
sys.setdefaultencoding('utf8')
FastpyAutoUpdate = True





class dbsample():
    def __init__(self):
        # init here
        self.mysqlPool = core.MysqlPool(pool_size=100,host='127.0.0.1',port=3306,user='root',passwd='myroot123',db='woxiu_qyg_user',charset='utf8')
        pass

    def test_mysql_pool(self, request, response_head):
	conn = self.mysqlPool.get()
        sql = "select * from test limit 1"
        #try:
        conn.execute(sql)
        rows = conn.fetchall()
        #except Exception,e:
        #    print str(e)

        self.mysqlPool.put(conn)
        #res = json.dumps(str(rows), ensure_ascii=True).encode('utf-8')
        #res = json.dumps(rows)

        return str(rows[0]['bid'])

